package com.authority.framework.web.service.impl;

import com.authority.framework.base.service.impl.BaseServiceImpl;
import com.authority.framework.base.entity.DTreeEntity;
import com.authority.framework.web.domain.SysMenuEntity;
import com.authority.framework.web.service.SysMenuService;
import org.beetl.sql.core.SQLManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: authority
 * @description: 菜单 impl层
 * @author: Mr.Yan
 * @create: 2018-11-15 13:47
 **/
@Service
@Transactional
public class SysMenuServiceImpl extends BaseServiceImpl<SysMenuEntity> implements SysMenuService {

	@Autowired
	private SQLManager sqlManager;

	//  参数
	private Map<String,String> paramMap = null;
	/**
	 * 查询用户的菜单
	 * @param userId
	 * @return
	 */
	@Override
	public List<SysMenuEntity> findListByUserId(Map paramMap) {
		return sqlManager.select("system/SysMenuSql.findListByUserId",SysMenuEntity.class,paramMap);
	}

	/** 
	* @Description: 查询菜单树集
	* @Param:  
	* @return:  
	* @Author: Mr.Yan 
	* @Date: 2018/12/12 
	*/
	
	@Override
	public List<DTreeEntity> findDTreeData() {
		paramMap = new HashMap<>();
		return sqlManager.select("system/SysMenuSql.findDTreeData",DTreeEntity.class,paramMap);
	}

	/**
	 * 查询角色菜单
	 * @param roleId
	 * @return
	 */
	@Override
	public List<SysMenuEntity> findListByRoleId(Integer roleId) {
		paramMap = new HashMap<>();
		paramMap.put("roleId",roleId.toString());
		return sqlManager.select("system/SysMenuSql.findListByRoleId",SysMenuEntity.class,paramMap);
	}

	/**
	 * 查询所有菜单
	 * @param ajaxMap
	 * @return
	 */
	@Override
	public List<SysMenuEntity> findMenuList(Map<String, Object> ajaxMap) {
		return sqlManager.select("system/SysMenuSql.pageInfo",SysMenuEntity.class,ajaxMap);
	}

}
